//
//  DateSearchBar.m
//  WOFishingBoat
//
//  Created by 郑逸凯 on 2019/1/4.
//  Copyright © 2019年 郑逸凯. All rights reserved.
//

#import "DateSearchBar.h"

@interface DateSearchBar ()
@property (nonatomic,strong)UIImageView *iconView;
@property (nonatomic,strong)UILabel *messageLabel;
@property (nonatomic,strong)UIButton *topControl;;
@end

@implementation DateSearchBar

- (void)addTarget:(nullable id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents {
    [self.topControl addTarget:target action:action forControlEvents:controlEvents];
}

- (instancetype)init {
    if (self = [super init]) {
        self.backgroundColor = RGB16(0xf0f0f0);
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 10;
        [self addSubview:self.iconView];
        [self addSubview:self.messageLabel];
        [self addSubview:self.topControl];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
//    CGFloat width = self.frame.size.width;
    CGFloat height = self.frame.size.height;
    self.iconView.frame = CGRectMake(8, (height - 15)/2, 15, 15);
    self.messageLabel.frame = CGRectMake(CGRectGetMaxX(self.iconView.frame) + 10, (height - 20)/2, 100, 20);
    self.topControl.frame = self.bounds;
}

- (UIImageView *)iconView {
    if (!_iconView) {
        UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"alb_search"]];
        imageView.userInteractionEnabled = YES;
        _iconView = imageView;
    }
    return _iconView;
}

- (UILabel *)messageLabel {
    if (!_messageLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.textColor = RGB16(0x999999);
        label.font = [UIFont systemFontOfSize:12];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = @"日期查询";
       _messageLabel = label;
    }
    return _messageLabel;
}

- (UIButton *)topControl {
    if (!_topControl) {
        _topControl = [UIButton buttonWithType:UIButtonTypeCustom];
    }
    return _topControl;
}



@end
